package com.zzy.threaddemo.old;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class FutureTaskTest {

	public static void main(String[] args) throws InterruptedException, ExecutionException {
		CountNum countNum=new CountNum();
		FutureTask<Integer> task=new FutureTask<Integer>(countNum);
		Thread thread=new Thread(task);
		thread.start();
		System.out.println(task.isDone());
//		try {
//			task.get(3, TimeUnit.SECONDS);
//		} catch (TimeoutException e) {
//			e.printStackTrace();
//		}
		System.out.println(task.get());   //阻塞获取执行结果
	
		System.out.println(task.isDone());
	}

}
